package org.aeon.fasttasks.core.properties;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.bind.DefaultValue;

import java.util.List;


/**
 * @author aeon
 * @createTime 2025/08/04  15:30
 * @description 任务配置
 */
@ConfigurationProperties(prefix = "fast-tasks")
public record TaskProperties(
        @DefaultValue("true") boolean enableTaskRecords,
        @DefaultValue List<String> taskClasses,
        @DefaultValue BatchWorkTasksExecutorProperties batchWorkTasksExecutorProperties,
        @DefaultValue BossTasksExecutorProperties bossTasksExecutorProperties) {

    /**
     * 线程池配置
     *
     * @param corePoolSize
     * @param maxPoolSize
     * @param queueCapacity
     * @param keepAliveSeconds
     * @param threadNamePrefix
     * @param allowCoreThreadTimeOut
     */
    public record BatchWorkTasksExecutorProperties(
            @DefaultValue("20") int corePoolSize,
            @DefaultValue("20") int maxPoolSize,
            @DefaultValue("1000") int queueCapacity,
            @DefaultValue("30") int keepAliveSeconds,
            @DefaultValue("work-thread-") String threadNamePrefix,
            @DefaultValue("true") boolean allowCoreThreadTimeOut) {
    }

    /**
     * 线程池配置
     *
     * @param corePoolSize
     * @param maxPoolSize
     * @param threadNamePrefix
     */
    public record BossTasksExecutorProperties(
            @DefaultValue("1") int corePoolSize,
            @DefaultValue("10") int maxPoolSize,
            @DefaultValue("boss-thread-") String threadNamePrefix) {
    }
}

